package com.stm.basicData.service.impl;

import java.util.Date;
import java.util.List;
import java.util.UUID;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.stm.basicData.mapper.ToolsAlarmMapper;
import com.stm.basicData.domain.ToolsAlarm;
import com.stm.basicData.service.IToolsAlarmService;
import com.stm.common.annotation.DataScope;
import com.stm.common.core.text.Convert;
import org.springframework.transaction.annotation.Transactional;

/**
 * 预警关联 服务层实现
 * 
 * @author wyc
 * @date 2019-04-08
 */
@Service
public class ToolsAlarmServiceImpl implements IToolsAlarmService 
{
	@Autowired
	private ToolsAlarmMapper toolsAlarmMapper;

	/**
     * 查询预警关联信息
     * 
     * @param id 预警关联ID
     * @return 预警关联信息
     */
    @Override
	public ToolsAlarm selectToolsAlarmById(String id)
	{
	    return toolsAlarmMapper.selectToolsAlarmById(id);
	}
	
	/**
     * 查询预警关联列表
     * 
     * @param toolsAlarm 预警关联信息
     * @return 预警关联集合
     */
	@Override
	@DataScope(tableAlias = "b7")
	public List<ToolsAlarm> selectToolsAlarmList(ToolsAlarm toolsAlarm)
	{
	    return toolsAlarmMapper.selectToolsAlarmList(toolsAlarm);
	}
	
    /**
     * 新增预警关联
     * 
     * @param toolsAlarm 预警关联信息
     * @return 结果
     */
	@Override
	@Transactional
	public int insertToolsAlarm(ToolsAlarm toolsAlarm)
	{
		toolsAlarm.setId(UUID.randomUUID().toString());
		toolsAlarm.setStatus("1");
		toolsAlarm.setCreateDate(new Date());
	    return toolsAlarmMapper.insertToolsAlarm(toolsAlarm);
	}
	
	/**
     * 修改预警关联
     * 
     * @param toolsAlarm 预警关联信息
     * @return 结果
     */
	@Override
	@Transactional
	public int updateToolsAlarm(ToolsAlarm toolsAlarm)
	{
		toolsAlarm.setUpdateDate(new Date());
	    return toolsAlarmMapper.updateToolsAlarm(toolsAlarm);
	}

	/**
     * 删除预警关联对象
     * 
     * @param ids 需要删除的数据ID
     * @return 结果
     */
	@Override
	public int deleteToolsAlarmByIds(String ids)
	{
		return toolsAlarmMapper.deleteToolsAlarmByIds(Convert.toStrArray(ids));
	}
	
}
